<!--{template pc/frame/header_simple_start}-->
<link rel="stylesheet" type="text/css" href="{MOD_PATH}/css/pc/admin.css?{VERHASH}"/>
<!--{template pc/frame/header_simple_end}-->
<div id="dzzoffice">
	<el-container>
		<el-header height="auto" style="padding: 0;z-index: 10;">
			<page-header :isscreenshow="false"></page-header>
		</el-header>
		<el-container>
		    <el-aside width="260px">
				<!--{template pc/page/adminLeft}-->
			</el-aside>
		    <el-main>
				<div class="page-content">
					<div id="center_title">基本信息</div>
					<el-scrollbar class="page-component__scroll">
						<div class="content" style="padding: 16px 25px;">
							<el-form ref="form" :model="formdata" label-width="200px">
								<el-form-item label="站点LOGO：">
									<el-upload
										class="avatar-uploader"
										action="{MOD_URL}&op=admin&do=uploadlogo"
										name="file"
										accept="image/png,image/svg"
										:on-success="handleLogoSuccess"
										:on-progress="handleLogoProgress"
										:before-upload="beforeLogoUpload"
										:show-file-list="false">
										<el-progress v-show="ispercentage" type="circle" :width="148" :percentage="percentage"></el-progress>
										<template v-if="imageUrl">
											<el-image fit="contain" :src="imageUrl"></el-image>
										</template>
										<i v-else class="el-icon-plus avatar-uploader-icon"></i>
										<div class="el-upload__tip tipTxt" slot="tip">只能上传png文件，且不超过2M</div>
									</el-upload>
								</el-form-item>
								
								
								<el-form-item label="站点名称：">
									<el-input class="maxWidth" v-model="formdata.sitename"></el-input>
									<p class="tipTxt">站点名称或简称，将显示在浏览器窗口标题等位置</p>
								</el-form-item>
								<el-form-item label="备案信息：">
									<el-input class="maxWidth" v-model="formdata.sitebeian"></el-input>
									<p class="tipTxt">支持html代码，面板可视区域大小为：263*235</p>
								</el-form-item>
								<el-form-item label="站点关键词：">
									<el-input class="maxWidth" type="textarea" autosize v-model="formdata.metakeywords"></el-input>
									<p class="tipTxt">平台SEO关键词</p>
								</el-form-item>
								<el-form-item label="站点描述：">
									<el-input class="maxWidth" type="textarea" autosize v-model="formdata.metadescription"></el-input>
									<p class="tipTxt">平台SEO关键词</p>
								</el-form-item>
								<el-form-item label="第三方统计代码：">
									<el-input class="maxWidth" type="textarea" autosize v-model="formdata.statcode"></el-input>
									<p class="tipTxt">支持html代码</p>
								</el-form-item>
								<el-form-item label="站点公开：">
									<el-radio-group v-model="formdata.overt">
										<el-radio border label="1">是</el-radio>
										<el-radio border label="0">否</el-radio>
									</el-radio-group>
									<p class="tipTxt">站点公开后任何人无需登录即可浏览站点内容</p>
								</el-form-item>
								<el-form-item label="站点关闭：">
									<el-radio-group v-model="formdata.bbclosed">
										<el-radio border label="1">是</el-radio>
										<el-radio border label="0">否</el-radio>
									</el-radio-group>
									<p class="tipTxt">暂时将平台关闭，其他人无法访问，但不影响管理员访问</p>
								</el-form-item>
								<el-form-item v-show="formdata.bbclosed == '1'" label="关闭平台的原因：">
									<el-input class="maxWidth" v-model="formdata.closedreason" type="textarea" autosize placeholder="">
									</el-input>
									<p class="tipTxt">平台关闭时出现的提示信息
</p>
								</el-form-item>
								<el-form-item>
									<el-button type="primary" @click="handleSubmit" :loading="btnloading">保存更改</el-button>
								</el-form-item>
							</el-form>
						</div>
					</el-scrollbar>
				</div>
						
			</el-main>
		  </el-container>
	</el-container>
</div>
<!--{template pc/components/headerAdmin/index}-->
<script type="text/javascript">
	new Vue({
		el: '#dzzoffice',
		data() {
			return {
				percentage:0,
				ispercentage:false,
				btnloading:false,
				formdata:{
					// sitelogo:'$setting[sitelogo]',//平台LOGO
					sitename:'',//平台名称
					sitebeian:'',//备案信息
					metakeywords:'',//关键词
					metadescription:'',//平台描述
					statcode:'',//统计代码
					overt:'',//公开
					bbclosed:'',//关闭平台
					closedreason:'',//关闭平台的原因,
				},
				imageUrl: 'data/attachment/sitelogo/sitelogo.png?{VERHASH}',
			}
		},
		created() {
			this.GetData();
		},
		methods: {
			GetData(){
				var self = this;
				$.post('{MOD_URL}&op=admin&do=basic&operation=getdata',function(json){
					var setting = json.data;
					self.formdata = {
						// sitelogo:'$setting[sitelogo]',//平台LOGO
						sitename:setting.sitename,//平台名称
						sitebeian:setting.sitebeian,//备案信息
						metakeywords:setting.metakeywords,//关键词
						metadescription:setting.metadescription,//平台描述
						statcode:setting.statcode,//统计代码
						overt:setting.overt,//公开
						bbclosed:setting.bbclosed,//关闭平台
						closedreason:setting.closedreason,//关闭平台的原因,
					};
				},'json')
			},
			beforeLogoUpload(file){
				var self = this;
				var isJPG = file.type === 'image/png';
				var isLt2M = file.size / 1024 / 1024 < 2;
				if (!isJPG) {
				  self.$message.error('站点LOGO只能是 PNG 格式!');
				}
				if (!isLt2M) {
				  self.$message.error('站点LOGO大小不能超过 2MB!');
				}
				return isJPG && isLt2M;
						
				self.ispercentage = true;
			},
			handleLogoSuccess(res, file){
				var random = Math.floor(Math.random()*50); 
				this.imageUrl = 'data/attachment/sitelogo/sitelogo.png?'+random;
			},
			handleLogoProgress(event, file, fileList) {
				var percent = parseInt(event.percent);
				this.percentage = percent;
				if(percent == 100){
					this.ispercentage = false;
					this.percentage = 0
				}
			},
			handleRouter(type){
				window.location.href = MOD_URL+'&op=admin&do='+type;
			},
			handleSubmit() {
				var self = this;
				self.btnloading = true;
				jQuery.post(MOD_URL+'&op=admin&do=basic',{
					settingsubmit:true,
					formhash:'{FORMHASH}',
					settingnew:self.formdata,
				},function(data){
					// console.log(data)
					if(data){
						self.$message({
							type:'success',
							message:'保存成功'
						});
					}else{
						self.$message.error('保存失败');
					}
					self.btnloading = false;
				},'json');
			},
		},
		mounted() {}
	})
</script>

<!--{template pc/frame/footer_simple}-->
